package com.chuangmei.com.arindoorlocationsystem.config;


import android.content.Intent;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.widget.TextView;

import com.chuangmei.com.arindoorlocationsystem.R;
import com.chuangmei.com.arindoorlocationsystem.base.BaseActivity;
import com.chuangmei.com.arindoorlocationsystem.config.fragment.ConfigListFragment;


import butterknife.BindView;

public class ConfigMessageActivity extends BaseActivity {
    @BindView(R.id.mTV_config_title)
    TextView mTV_config_title;

    @Override
    protected void initLayout() {
        setContentView(R.layout.activity_config);
    }

    @Override
    protected void initView() {
        //实例化FragmentOne
        ConfigListFragment configListFragment = new ConfigListFragment();
        //获取碎片管理者
        FragmentManager mFragmentManager = getSupportFragmentManager();
        initDefaultFragment(configListFragment, mFragmentManager);
    }

    //初始化默认fragment的加载
    private void initDefaultFragment(ConfigListFragment configListFragment, FragmentManager mFragmentManager) {

        //开启一个事务
        FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
        //add：往碎片集合中添加一个碎片；
        //replace：移除之前所有的碎片，替换新的碎片（remove和add的集合体）(很少用，不推荐，因为是重新加载，所以消耗流量)
        //参数：1.公共父容器的的id  2.fragment的碎片
        fragmentTransaction.add(R.id.mFL_config, configListFragment);
        // 将事务添加到回退栈，这样用户就可以通过“返回键”回到替换Fragment的上一个状态
        //fragmentTransaction.addToBackStack(null);
        //提交事务
        fragmentTransaction.commit();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    }

    public void chengTitle(String string) {
        mTV_config_title.setText(string);
    }

}
